winsafe\mf\com_interfaces/
imftopologynode.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::mf::vts::*;
6use crate::ole::privs::*;
7use crate::prelude::*;
8
9com_interface! { IMFTopologyNode: "83cf873a-f6da-4bc8-823f-bacfd55dc430";
10	/// [`IMFTopologyNode`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nn-mfidl-imftopologynode)
11	/// COM interface.
12	///
13	/// Automatically calls
14	/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
15	/// when the object goes out of scope.
16	///
17	/// Usually created with
18	/// [`MFCreateTopologyNode`](crate::MFCreateTopologyNode) function.
19	///
20	/// # Examples
21	///
22	/// ```no_run
23	/// use winsafe::{self as w, prelude::*, co};
24	///
25	/// let topology_node = w::MFCreateTopologyNode(co::MF_TOPOLOGY::OUTPUT_NODE)?;
26	/// # w::HrResult::Ok(())
27	/// ```
28}
29
30impl mf_IMFAttributes for IMFTopologyNode {}
31impl mf_IMFTopologyNode for IMFTopologyNode {}
32
33/// This trait is enabled with the `mf` feature, and provides methods for
34/// [`IMFTopologyNode`](crate::IMFTopologyNode).
35///
36/// Prefer importing this trait through the prelude:
37///
38/// ```no_run
39/// use winsafe::prelude::*;
40/// ```
41pub trait mf_IMFTopologyNode: mf_IMFAttributes {
42	/// [`IMFTopologyNode::CloneFrom`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-clonefrom)
43	/// method.
44	fn CloneFrom(&self, node: &impl mf_IMFTopologyNode) -> HrResult<()> {
45		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).CloneFrom)(self.ptr(), node.ptr()) })
46			.to_hrresult()
47	}
48
49	/// [`IMFTopologyNode::ConnectOutput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-connectoutput)
50	/// method.
51	fn ConnectOutput(
52		&self,
53		output_index: u32,
54		downstream_node: &impl mf_IMFTopologyNode,
55		input_index_on_downstream_node: u32,
56	) -> HrResult<()> {
57		HrRet(unsafe {
58			(vt::<IMFTopologyNodeVT>(self).ConnectOutput)(
59				self.ptr(),
60				output_index,
61				downstream_node.ptr(),
62				input_index_on_downstream_node,
63			)
64		})
65		.to_hrresult()
66	}
67
68	/// [`IMFTopologyNode::DisconnectOutput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-disconnectoutput)
69	/// method.
70	#[must_use]
71	fn DisconnectOutput(&self, output_index: u32) -> HrResult<()> {
72		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).DisconnectOutput)(self.ptr(), output_index) })
73			.to_hrresult()
74	}
75
76	/// [`IMFTopologyNode::GetInput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getinput)
77	/// method.
78	///
79	/// Returns the node and the index of the output stream that is connected to
80	/// this node's input stream.
81	#[must_use]
82	fn GetInput(&self, input_index: u32) -> HrResult<(IMFTopologyNode, u32)> {
83		let mut queried = unsafe { IMFTopologyNode::null() };
84		let mut output_index_downstream_node = 0u32;
85		HrRet(unsafe {
86			(vt::<IMFTopologyNodeVT>(self).GetInput)(
87				self.ptr(),
88				input_index,
89				queried.as_mut(),
90				&mut output_index_downstream_node,
91			)
92		})
93		.to_hrresult()
94		.map(|_| (queried, output_index_downstream_node))
95	}
96
97	/// [`IMFTopologyNode::GetInputCount`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getinputcount)
98	/// method.
99	#[must_use]
100	fn GetInputCount(&self) -> HrResult<u32> {
101		let mut c = 0u32;
102		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).GetInputCount)(self.ptr(), &mut c) })
103			.to_hrresult()
104			.map(|_| c)
105	}
106
107	/// [`IMFTopologyNode::GetNodeType`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getnodetype)
108	/// method.
109	#[must_use]
110	fn GetNodeType(&self) -> HrResult<co::MF_TOPOLOGY> {
111		let mut ty = co::MF_TOPOLOGY::default();
112		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).GetNodeType)(self.ptr(), ty.as_mut()) })
113			.to_hrresult()
114			.map(|_| ty)
115	}
116
117	/// [`IMFTopologyNode::GetObject`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getobject)
118	/// method.
119	#[must_use]
120	fn GetObject<T>(&self) -> HrResult<T>
121	where
122		T: ole_IUnknown,
123	{
124		let mut queried = unsafe { T::null() };
125		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).GetObject)(self.ptr(), queried.as_mut()) })
126			.to_hrresult()
127			.map(|_| queried)
128	}
129
130	/// [`IMFTopologyNode::GetOutput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getoutput)
131	/// method.
132	///
133	/// Returns the node and the index of the input stream that is connected to
134	/// this node's output stream.
135	#[must_use]
136	fn GetOutput(&self, output_index: u32) -> HrResult<(IMFTopologyNode, u32)> {
137		let mut queried = unsafe { IMFTopologyNode::null() };
138		let mut input_index_downstream_node = 0u32;
139		HrRet(unsafe {
140			(vt::<IMFTopologyNodeVT>(self).GetOutput)(
141				self.ptr(),
142				output_index,
143				queried.as_mut(),
144				&mut input_index_downstream_node,
145			)
146		})
147		.to_hrresult()
148		.map(|_| (queried, input_index_downstream_node))
149	}
150
151	/// [`IMFTopologyNode::GetOutputCount`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getoutputcount)
152	/// method.
153	#[must_use]
154	fn GetOutputCount(&self) -> HrResult<u32> {
155		let mut c = 0u32;
156		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).GetOutputCount)(self.ptr(), &mut c) })
157			.to_hrresult()
158			.map(|_| c)
159	}
160
161	/// [`IMFTopologyNode::GetTopoNodeID`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-gettoponodeid)
162	/// method.
163	#[must_use]
164	fn GetTopoNodeID(&self) -> HrResult<u64> {
165		let mut id = 0u64;
166		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).GetTopoNodeID)(self.ptr(), &mut id) })
167			.to_hrresult()
168			.map(|_| id)
169	}
170
171	/// [`IMFTopologyNode::SetObject`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-setobject)
172	/// method
173	fn SetObject(&self, object: &impl ole_IUnknown) -> HrResult<()> {
174		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).SetObject)(self.ptr(), object.ptr()) })
175			.to_hrresult()
176	}
177
178	/// [`IMFTopologyNode::SetTopoNodeID`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-settoponodeid)
179	/// method.
180	fn SetTopoNodeID(&self, topo_id: u64) -> HrResult<()> {
181		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).SetTopoNodeID)(self.ptr(), topo_id) })
182			.to_hrresult()
183	}
184}